home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: int main() vs int main(void)
- Date: Fri, 09 Feb 96 23:59:01 GMT
- Organization: none
- Message-ID: <823910341snz@genesis.demon.co.uk>
- References: <1996Feb7.201848.18734@atlas.tntech.edu> <danpop.823791491@rscernix>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <danpop.823791491@rscernix> danpop@mail.cern.ch "Dan Pop" writes:
-
- >In <1996Feb7.201848.18734@atlas.tntech.edu> jad7084@tntech.edu (Jim Davis)
- > writes:
- >
- >>Okay, void main() is naughty, but there's something else I've been
- >>wondering about, and I can't find it in the FAQ.
- >>
- >>Is there a difference between
- >>
- >> int main()
- >> int main(void)
- >>
- >>? () is equivalent to (void), right? Does it matter? Am I worried about
- >>nothing?
- >
- >As part of a function definition, the two forms are 100% equivalent.
- >
- >As function declarations, the second is a prototype while the first
- >allows main to be called with any (number and type of) arguments.
-
- The first doesn't tell you the correct number and types of the
- arguments you must supply, or let the compiler check them. However the
- arguments you supply must still match those in the function definition if
- you want to avoid undefined behaviour.
-
- It is however correct to say that the first form as a declaration is
- compatible with any (fixed argument) declaration/definition of main that
- returns int.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-